﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace Lyon.Utility
{
    /// <summary>
    /// 文件工具
    /// </summary>
    static public class FileUtility
    {
        /// <summary>
        /// 获取文件的MD5值。
        /// </summary>
        /// <param name="stream">数据流。</param>
        /// <returns>返回MD5值。</returns>
        static public string GetMD5Value(Stream stream)
        {
            System.Security.Cryptography.MD5CryptoServiceProvider md5Provider = new System.Security.Cryptography.MD5CryptoServiceProvider();
            byte[] hash_byte = md5Provider.ComputeHash(stream);
            string result = BitConverter.ToString(hash_byte);
            result = result.Replace("-", "");
            return result;
        }
    }
}
